﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdDbBaseLongTransactionPE : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbBaseLongTransactionPE(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdDbBaseLongTransactionPE_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbBaseLongTransactionPE obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbBaseLongTransactionPE()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdDbBaseLongTransactionPE(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbBaseLongTransactionPE cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdDbBaseLongTransactionPE_cast(OdRxObject.getCPtr(pObj));
			OdDbBaseLongTransactionPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdDbBaseLongTransactionPE_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdDbBaseLongTransactionPE_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdDbBaseLongTransactionPE_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbBaseLongTransactionPE createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdDbBaseLongTransactionPE_createObject();
			OdDbBaseLongTransactionPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbBaseLongTransactionPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbStub destinationBlock(OdRxObject pLT)
		{
			IntPtr intPtr = GlobalsPINVOKE.OdDbBaseLongTransactionPE_destinationBlock(this.swigCPtr, OdRxObject.getCPtr(pLT));
			OdDbStub result = (intPtr == IntPtr.Zero) ? null : new OdDbStub(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool workSetHas(OdRxObject pLT, OdDbStub pId)
		{
			bool result = GlobalsPINVOKE.OdDbBaseLongTransactionPE_workSetHas(this.swigCPtr, OdRxObject.getCPtr(pLT), OdDbStub.getCPtr(pId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdRxIterator newWorkSetIterator(OdRxObject pLT, bool incRemoved, bool incSecondary)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdDbBaseLongTransactionPE_newWorkSetIterator__SWIG_0(this.swigCPtr, OdRxObject.getCPtr(pLT), incRemoved, incSecondary);
			OdRxIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdRxIterator newWorkSetIterator(OdRxObject pLT, bool incRemoved)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdDbBaseLongTransactionPE_newWorkSetIterator__SWIG_1(this.swigCPtr, OdRxObject.getCPtr(pLT), incRemoved);
			OdRxIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdRxIterator newWorkSetIterator(OdRxObject pLT)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdDbBaseLongTransactionPE_newWorkSetIterator__SWIG_2(this.swigCPtr, OdRxObject.getCPtr(pLT));
			OdRxIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdRxIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbStub getOwner(OdDbStub pId)
		{
			IntPtr intPtr = GlobalsPINVOKE.OdDbBaseLongTransactionPE_getOwner(this.swigCPtr, OdDbStub.getCPtr(pId));
			OdDbStub result = (intPtr == IntPtr.Zero) ? null : new OdDbStub(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbStub getId(OdRxObject pObj)
		{
			IntPtr intPtr = GlobalsPINVOKE.OdDbBaseLongTransactionPE_getId(this.swigCPtr, OdRxObject.getCPtr(pObj));
			OdDbStub result = (intPtr == IntPtr.Zero) ? null : new OdDbStub(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
